---@diagnostic disable: lowercase-global, undefined-global, trailing-space

GLOBAL.setmetatable(env,{__index=function(t,k) return GLOBAL.rawget(GLOBAL,k) end})

---@type string
local modid = 'webber_the_trainer' -- 定义唯一modid

GLOBAL.WEBBER_THE_TRAINER_API = env

---@type LAN_TOOL_COORDS
COORDS_webber_the_trainer = require('core_'..modid..'/utils/coords')
---@type LAN_TOOL_SUGARS
SUGAR_webber_the_trainer = require('core_'..modid..'/utils/sugar')

rawset(GLOBAL,'COORDS_webber_the_trainer',COORDS_webber_the_trainer)
rawset(GLOBAL,'SUGAR_webber_the_trainer',SUGAR_webber_the_trainer)

PrefabFiles = {
	'webber_the_trainer_module_buffs',
	'webber_the_trainer_module_dishes',
	'webber_the_trainer_module_particle',
	----
	'fx_staff_arachnidnexus_fireballburning',
	'fx_webbert_skitter_head',
	'fx_webbert_skitter_heallaser',
	'fx_webbert_misc',
	----
	'staff_arachnidnexus',
	'webbert_bread',
	'webbert_skitter',
	'webbert_pack',
	'webbert_sack',
	'webbert_book',
	'webbert_seedbox',

	'webbert_gameconsole',
}

---@type asset[]
Assets = {
	Asset("SOUNDPACKAGE","sound/webbert_staff_soundfx.fev"),
	Asset("SOUND","sound/webbert_staff_soundfx.fsb"),

	Asset("ANIM","anim/fx_webbert_soul.zip"),

	Asset("ANIM","anim/fx_goldenframeflow.zip"),
	Asset("ATLAS","images/ui/webbert_rt_btns.xml"),

	Asset( "ATLAS", "images/frames/merged_img_1750061493.xml" ),
	Asset("ATLAS","images/ui/webbert_scrollablelist.xml"),
	
	-- game ui
	Asset("ATLAS","images/ui/webbert_game_logo_tetris.xml"),
}

----------------------------------------
----------------------------------------
------由于导入文件较多,请务必注意顺序------
------由于导入文件较多,请务必注意顺序------
------由于导入文件较多,请务必注意顺序------
----------------------------------------
----------------------------------------

-- 导入mod配置
for _,v in ipairs({
	'_lang',
	'_staff_key',
	'_rt_panel',
	'_goat_herd_highlight',
	'_life',
}) do TUNING[string.upper('CONFIG_'..modid..v)] = GetModConfigData(modid..v) end


-- 导入常量表
modimport('scripts/core_'..modid..'/data/tuning.lua')

-- 导入工具
modimport('scripts/core_'..modid..'/utils/_register.lua')

-- 导入功能API
modimport('scripts/core_'..modid..'/api/_register.lua')

-- 导入语言文件
modimport('scripts/core_'..modid..'/languages/'..TUNING[string.upper('CONFIG_'..modid..'_LANG')]..'.lua')

-- 皮肤API
modimport('scripts/api_skins/'..modid..'_skins') -- 皮肤api

-- 导入人物
modimport('scripts/data_avatar/data_avatar_webbert.lua')

-- 导入调用器
-- modimport('scripts/core_'..modid..'/callers/caller_attackperiod.lua')
-- modimport('scripts/core_'..modid..'/callers/caller_badge.lua')
modimport('scripts/core_'..modid..'/callers/caller_ca.lua')
modimport('scripts/core_'..modid..'/callers/caller_changeactionsg.lua')
modimport('scripts/core_'..modid..'/callers/caller_container.lua')
modimport('scripts/core_'..modid..'/callers/caller_dish.lua')
modimport('scripts/core_'..modid..'/callers/caller_keyhandler.lua')
-- modimport('scripts/core_'..modid..'/callers/caller_onlyusedby.lua')
modimport('scripts/core_'..modid..'/callers/caller_recipes.lua')
-- modimport('scripts/core_'..modid..'/callers/caller_stack.lua')

-- 导入零散功能模块 (自用 可以无视)
modimport('scripts/core_webber_the_trainer/managers/atk_speed_from_alt.lua') -- 功能(无需修改): alt写的修改攻速模块
-- modimport('scripts/core_webber_the_trainer/managers/bugfix_aoetargeting.lua') -- 当你使用官方组件来写技能时,貌似会因为没有正确移除 reticule 组件,导致玩家的轮盘施法放不出来,本文件就是用来修复这个bug的
-- modimport('scripts/core_webber_the_trainer/managers/bugfix_souljump.lua') -- 当你使用官方组件来写武器技能时, 会导致和 小恶魔的灵魂跳跃 冲突, 具体我忘了, 总之这个文件就是用来修复这个bug的
-- modimport('scripts/core_webber_the_trainer/managers/build_data_transfer.lua') -- 功能(需要填写): 制作物品过程涉及数据传输 (只能传输1件原材料的数据)
-- modimport('scripts/core_webber_the_trainer/managers/cantequip_whennodurability.lua') -- 功能(无需修改): 本文件用来管理,装备耐久用尽时的逻辑
-- modimport('scripts/core_webber_the_trainer/managers/cd_in_itemtile.lua') -- 功能(无需修改): 在物品栏以数字形式显示的cd
modimport('scripts/core_webber_the_trainer/managers/dmg_sys.lua') -- 管理: 用这个文件管理伤害处理吧
modimport('scripts/core_webber_the_trainer/managers/event_hook.lua') -- 功能(需要填写): 勾 event
modimport('scripts/core_webber_the_trainer/managers/invincible.lua') -- 功能(无需修改): 设置无敌的
modimport('scripts/core_webber_the_trainer/managers/is_mod_enabled.lua') -- 功能(无需修改): 判断某个mod有没有开启 的前置
-- modimport('scripts/core_webber_the_trainer/managers/last_atk_weapon.lua') -- 功能(无需修改): 获取攻击者上次使用的武器
modimport('scripts/core_webber_the_trainer/managers/misc.lua') -- 杂项
modimport('scripts/core_webber_the_trainer/managers/participate_kill.lua') -- 功能(无需修改): 联合击杀(参与击杀), 判断生物死亡时, 某个玩家有没有贡献伤害(参与战斗)
-- modimport('scripts/core_webber_the_trainer/managers/quick_announce.lua') -- 功能(需要填写): alt + 左键点击库存物品宣告
-- modimport('scripts/core_webber_the_trainer/managers/skin_container_ui.lua') -- 功能(需要填写): 箱子的UI皮肤
-- modimport('scripts/core_webber_the_trainer/managers/sort_recipes.lua') -- 功能(需要填写): 给配方排序
modimport('scripts/core_webber_the_trainer/managers/trade.lua') -- 功能(无需修改,但需要填写其他地方): 添加通用的交易升级功能
modimport('scripts/core_webber_the_trainer/managers/_auto_regist_animandtex.lua') -- (必须)无需关心: 帮助其他框架载入材质和注册用的
modimport('scripts/core_webber_the_trainer/managers/keyhandle.lua')
modimport('scripts/core_webber_the_trainer/managers/rpchandle.lua')

-- 导入UI
modimport('scripts/core_webber_the_trainer/ui/webbert_panel.lua')
modimport('scripts/core_webber_the_trainer/ui/rt_panel.lua')
modimport('scripts/core_webber_the_trainer/ui/webbert_life_panel.lua') -- 生涯
modimport('scripts/core_webber_the_trainer/ui/gameconsole.lua')

-- 注册客机组件
AddReplicableComponent('webbert_soul')
AddReplicableComponent('webbert_skitter_misc')
AddReplicableComponent('webbert_seedbox')
AddReplicableComponent('webbert_life')

-- 导入 skins
---@type string[]
local skin_files = {
	-- 'myspear',
	'cookpot',
	'staff_arachnidnexus',
}
for _,v in ipairs(skin_files) do
	modimport('scripts/core_'..modid..'/skins/'..v..'.lua')
end

-- 导入钩子 It's my勾
---@type string[]
local files_hook = {
	'a',
	'RegisterInventoryItemAtlas',
	'webbert_soul', -- 血契
	'soul_addevent', -- 血契相关, 添加一些事件
	'page_box', -- 翻页容器
	'page_box_sack',
	'webbert_skitter', -- skitter相关 容器UI等
	'edible', -- edible组件没有加edible可还行
	'findstaff_ininv', -- 按轮盘键找手杖
	'stamp',
	'tp',
	'fix_dish', -- 部分料理的修改
	'hovertext', -- 悬浮文本
	'webbert_seedbox', -- 真空种子匣 ui, rpchandle
	'goat_mark', -- 电羊出生点
	'life', -- 生涯
	'justice',
	'tune', -- 一些体验的调整
	'webbert_gameconsole', -- 游戏机
}
for _,v in ipairs(files_hook) do
	modimport('scripts/core_'..modid..'/hooks/'..v..'.lua')
end

-- sg
modimport('scripts/core_webber_the_trainer/sg/webbert_blanksg.lua')
modimport('scripts/core_webber_the_trainer/sg/webbert_whistle.lua')
modimport('scripts/core_webber_the_trainer/sg/webbert_quickchop.lua')
modimport('scripts/core_webber_the_trainer/sg/webbert_give.lua')